#pragma once

namespace cr
{
	template <typename T>
	class Offset
	{
	public:

		T*				operator -> ()				{ return Get(); }
		T&				operator * ()				{ return *Get(); }
		
		T*				operator [] (size_t index)	{ return &((T*)Get())[index]; }

		void			Set(T* pObj)				{ m_offset = (uint8_t*)pObj - (uint8_t*)this; }
		void			Set(uint32_t offset)		{ m_offset = offset; }

		T*				Get() const					{ return static_cast<T*>(((uint8_t*)this) + m_offset); }

	private:

		cr::uint32_t	m_offset;
	};
}